package com.az.alibaba.core;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.az.alibaba.downloader.DemoSpider;

public class Run {

	private static final Logger log = LoggerFactory.getLogger(Run.class);

	public static void main(String[] args) {
		log.info("爬虫启动...");
		InputStream in = ClassLoader.getSystemResourceAsStream("application.properties");
		Properties props = new Properties();
		try {
			props.load(in);
		} catch (IOException e) {
			log.error("加载application.properties出错:", e);
			return;
		} finally {
			try {
				in.close();
			} catch (IOException e) {
				log.error("close inputStream error:", e);
			}
		}
		for (Object key : props.keySet()) {
			log.debug("{}:{}", key.toString(), props.getProperty(key.toString()));
		}
		log.info("设置System的properties...");
		for(Object key : props.keySet()){
			System.setProperty(key.toString(), props.getProperty(key.toString()));
		}
		log.info("启动爬虫--->");
		DemoSpider.run();
		log.info("任务完成!");
	}

}
